
const fs = require('fs')

const p = new Promise(function(resolve,reject){
    fs.readFile("为学.txt",(err,data)=>{
        if(err){
            reject(err)
        }
        resolve(data)
    })
})


//回调函数
p.then(function(value){
    console.log(value.toString())
}),function(reason){
    console.log("文件读取失败")
}